package com.deductive.service.special.impl;

import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deductive.domain.special.SpecialHospital;
import com.deductive.mapper.special.SpecialHospitalMapper;
import com.deductive.service.special.SpecialHospitalService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 47338
* @description 针对表【special_hospital(医院)】的数据库操作Service实现
* @createDate 2025-09-08 17:30:53
*/
@Service
public class SpecialHospitalServiceImpl extends ServiceImpl<SpecialHospitalMapper, SpecialHospital>
    implements SpecialHospitalService {
    @Override
    public List<Tree<Object>> listTree() {
        TreeNodeConfig treeNodeConfig = new TreeNodeConfig();
        treeNodeConfig.setIdKey("id");
        treeNodeConfig.setNameKey("medicalName");
        treeNodeConfig.setParentIdKey("parentId");
        List<SpecialHospital> list =this.list();
        List<Tree<Object>> treeList = TreeUtil.build(list, 0, treeNodeConfig, (specialHospital, tree) -> {
            tree.setId(specialHospital.getId()); // 设置节点ID
            tree.setName(specialHospital.getName()); // 设置节点名称（显示文本）
            tree.setParentId(specialHospital.getParentId());
            tree.putExtra("ownerCountry", specialHospital.getOwnerCountry());
            tree.putExtra("ownerProvince", specialHospital.getOwnerProvince());
            tree.putExtra("city", specialHospital.getCity());
            tree.putExtra("lon", specialHospital.getLon());
            tree.putExtra("lat", specialHospital.getLat());
            tree.putExtra("address", specialHospital.getAddress());
            tree.putExtra("hospitalType", specialHospital.getHoslitalType());
            tree.putExtra("hospitalGrade", specialHospital.getHoslitalGrade());
            tree.putExtra("bedsNumber", specialHospital.getBedsNumber());
            tree.putExtra("subordination", specialHospital.getSubordination());
            tree.putExtra("phoneNumber", specialHospital.getPhoneNumber());
            tree.putExtra("numberOfDepartments", specialHospital.getNoOfDepts());
            tree.putExtra("numberOfAgentia", specialHospital.getNoOfDrugs());
            tree.putExtra("numberOfNurses", specialHospital.getNoOfNurses());
            tree.putExtra("numberOfMedMechPersonnel", specialHospital.getNoOfMedMechPersonnel());
            tree.putExtra("numberOfAdmissions", specialHospital.getAnnNoOfAdmissions());
            tree.putExtra("hospitalStaff", specialHospital.getHospitalStaff());
            tree.putExtra("score", specialHospital.getScore());
            tree.putExtra("description", specialHospital.getDescription());
            tree.putExtra("department", specialHospital.getDepartment());
            tree.putExtra("englishname", specialHospital.getEnglishname());
            tree.putExtra("evaluationOfEvaluations", specialHospital.getEvaluationOfEvaluations());
            tree.putExtra("website", specialHospital.getWebsite());
            tree.putExtra("dataSource", specialHospital.getDataSource());
            tree.putExtra("downloadFolderurl", specialHospital.getDownloadFolderurl());
        });
        return treeList;
    }
}




